<?php
quanli_require('framework/PHPMailer/class.phpmailer.php');

class mailerFactory{
	public static function create(){
	    
		$sender_name = G_MAIL_SENDER_NAME;
		$getencoding = mb_detect_encoding(G_MAIL_SENDER_NAME);
		if ($getencoding != G_MAIL_CHARSET)
			$sender_name = iconv($getencoding,G_MAIL_CHARSET . "//IGNORE",$sender_name);
		
		$mail = new PHPMailer(true);
		$mail->SMTPDebug = 0;
		$mail->IsSMTP();
		
		$mail->CharSet = G_MAIL_CHARSET;
		
		$mail->AddReplyTo(G_MAIL_SMTP_USER,$sender_name);
		$mail->Host       = G_MAIL_SMTP_SERVER; // SMTP server
		$mail->SMTPAuth   = true;                 // enable SMTP authentication
		$mail->Port       = G_MAIL_SMTP_PORT;                    // set the SMTP port for the GMAIL server
		$mail->Username   = G_MAIL_SMTP_USER; // SMTP account username
		$mail->Password   = G_MAIL_SMTP_PWD;        // SMTP account password
		
		
		$mail->SetFrom(G_MAIL_SMTP_USER, $sender_name);
		return $mail;
    }
}